package com.stn.zjx.givingtreasure.net.impl;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheEntity;
import com.lzy.okgo.cache.CacheMode;
import com.lzy.okgo.callback.StringCallback;
import com.stn.zjx.givingtreasure.net.MsgApi;
import com.stn.zjx.givingtreasure.net.QQWeixinApi;
import com.stn.zjx.givingtreasure.net.UserApi;
import com.stn.zjx.givingtreasure.service.UserService;
import com.stn.zjx.givingtreasure.utils.ToolsUtils;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class MsgNetImpl {
    /**
     * @apiNote 获取消息类型列表

     * @param token 昵称

     * @param tag 标签
     * @param callback 请求回调

     */
    public  static  void query_msg_type_list(String token,String tag, StringCallback callback){
        OkGo.<String>post(MsgApi.query_msg_type_list)
                .tag(tag)
                .cacheTime(CacheEntity.CACHE_NEVER_EXPIRE)
                .cacheKey(tag)
                .cacheMode(CacheMode.FIRST_CACHE_THEN_REQUEST)
                .isSpliceUrl(true)
                .upJson("")
                .params("token",token,true)
                .execute(callback);
    }

    /**
     * @apiNote 获取消息未读操作

     * @param token 昵称

     * @param tag 标签
     * @param callback 请求回调

     */
    public  static  void query_get_no_read_all_msg(String token,String tag, StringCallback callback){
        OkGo.<String>post(MsgApi.query_get_no_read_all_msg)
                .tag(tag)
                .cacheTime(CacheEntity.CACHE_NEVER_EXPIRE)
                .cacheKey(tag)
                .cacheMode(CacheMode.FIRST_CACHE_THEN_REQUEST)
                .isSpliceUrl(true)
                .upJson("")
                .params("token",token,true)
                .execute(callback);
    }
    /**
     * @apiNote 获取消息未读操作

     * @param pageNow 页数
     * @param pageSize 条数
     * @param msgType 消息类型
     *
     * @param tag 标签
     * @param callback 请求回调

     */
    public  static  void query_get_msg_list(Integer pageNow,Integer pageSize,Integer msgType,String token,String tag, StringCallback callback){

         Map<String,String> map=new HashMap<>();
          map.put("pageNow",pageNow+"");
          map.put("pageSize",pageSize+"");
          map.put("msgType",msgType+"");
          map.put("token",token+"");
         OkGo.<String>post(MsgApi.query_get_msg_list)
                .tag(tag)
                .cacheTime(CacheEntity.CACHE_NEVER_EXPIRE)
                .cacheKey(tag)
                .cacheMode(CacheMode.FIRST_CACHE_THEN_REQUEST)
                .isSpliceUrl(true)
                 .upJson("")
                 .params(map)
                .execute(callback);
    }
}
